//
// Fenetre.cpp for rush in /home/peelou/SVN/rush-mars-2016-dewulf_f
// 
// Made by gery baudry
// Login   <baudry_g@epitech.net>
// 
// Started on  Sat Mar  9 13:14:09 2013 gery baudry
// Last update Fri Apr 19 10:37:05 2013 gery baudry
//

#include	<iostream>
#include	<cstdio>
#include	<list>
#include	"Fenetre.hpp"

MaFenetre::MaFenetre() : win(new QWidget), tab(new QTabWidget), command(new QPlainTextEdit), lay(new QHBoxLayout), envoyer(new QPushButton("Envoyer", this)), ofile("try", std::ios::out)
{
  setFixedSize(800, 600);
  this->creerTab();
  this->creerLayout();
}

void		MaFenetre::creerTab()
{
  this->envoyer->setFixedSize(100, 50);
  QObject::connect(this->envoyer, SIGNAL(clicked()), this, SLOT(envoie_commande()));
  this->tab->addTab(this->command, "Commande");
  this->tab->setFixedSize(650, 550);
}

void		MaFenetre::newTab(const std::string buffer)
{
  QLabel		*cuisine = new QLabel(buffer);

  this->tab->addTab(cuisine, "Cuisine");
}

void		MaFenetre::creerLayout()
{
  this->lay->addWidget(this->tab);
  this->lay->addWidget(this->envoyer);
  this->win->setLayout(this->lay);
  setCentralWidget(this->win);
}

void		MaFenetre::envoie_commande()
{
  QString			str;

  str = this->command->toPlainText();
  std::cout << str.toStdString() << std::endl;
  this->command->clear();
  QMessageBox::information(this, tr("&envoyer"), tr("Commande Envoye"));
}
